<?php
/* this could be done in an iframe with a meta refresh tag and a transition tag.
the ideal aspect of that would be the new ads each time
*/
?>



<?php
	$access_token = $_SESSION['access_token'];

/* Create a TwitterOauth object with consumer/user tokens. */
	$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);

	$jsonDecode = $connection->get('statuses/home_timeline');

	$rowOnOff = "rowOff";
?>
<span id="timelinetitle"><?php echo $access_token['screen_name']; ?></span><span id="timelinecount"><?php echo count($jsonDecode); ?> tweet results</span>
<hr id="simplehr" />
<table id="timelinetable" cellspacing="0" cellpadding="5">
<?php
	foreach ($jsonDecode as $timelineEntry)
	{
?>
	<tr id="<?php echo $rowOnOff; ?>" onmouseover="this.id='rowOn';" onmouseout="this.id='<?php echo $rowOnOff; ?>';">
		<td valign="top">
			<a class="dock-item2" href="http://www.twitter.com/<?php echo $timelineEntry->user->screen_name; ?>"><img src="<?php echo $timelineEntry->user->profile_image_url; ?>" alt="(~.~)" title="<?php echo $timelineEntry->user->screen_name;?>" width="48" height="48" border="0" /></a>
		</td>
		<td valign="top">
			<a href="http://www.twitter.com/<?php echo $timelineEntry->user->screen_name; ?>"><?php echo $timelineEntry->user->screen_name; ?></a>
			<?php
				//if the tweet is detected to be an unbroken string of characters from a to g, 
				//it either is, or can be interpreted to be, music
				if ( preg_match('/^[a-gA-G]+$/', strtolower($timelineEntry->text)) )
				{
			?>
				<img src="msctxt.php?rawtweet=<?php echo urlencode($timelineEntry->text); ?>" />
			<?php
				}
				else
				{
			?>
				<span><?php echo ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $timelineEntry->text); ?></span>

			<?php
				}
			?>
			
		</td>
	</tr>
<?php
		if ($rowOnOff == "rowOff")
			$rowOnOff = "rowOn";
		else
			$rowOnOff = "rowOff";
	}
	
?> 
</table>